# -*- coding: utf-8 -*-
# @Author: slp
# @Date:   2017-09-18 10:08:52
# @Last Modified by:   slp
# @Last Modified time: 2017-09-18 16:53:12

import xml.dom.minidom
# from xml.dom.minidom import parse

# document = """\
# <regddd>
#  <box
# </regddd>
# """

xml_file = "test.xml"

dom = xml.dom.minidom.parse(xml_file)

nodes = dom.getElementsByTagName("reg")
for node in nodes:
	# note.get
	box_nodes = node.getElementsByTagName("box")
	for box in box_nodes:
		print "======"
		print 'box.tagName: ',box.tagName
		print 'box.getAttribute("hibit"): ',box.getAttribute("hibit")
		cnodes = box.getElementsByTagName("c")
		for cnode in cnodes:
			print "cnode.nodeName: ", cnode.nodeName
			print "cnode.nodeType: ", cnode.nodeType
			fchild = cnode.firstChild
			if fchild == None:
				continue
			if fchild.nodeType == node.TEXT_NODE:
				print "fchild.nodeName: ", fchild.nodeName
				print "fchild.nodeType: ", fchild.nodeType
				print "fchild.nodeValue: ", fchild.nodeValue


# print dir(nodes[0])
# print nodes[0].toprettyxml()
print nodes[0].toxml()
